Diff Press 5 Click
Diff Press 5 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jan 2025.
- Type : ADC/I2C type
Software Support
Example Description
This example demonstrates the use of the Diff Press 5 Click board. It showcases how to initialize the device, calibrate the zero-pressure offset, and read the differential pressure data in Pascals (Pa) from the sensor.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.DiffPress5
Example Key Functions
- diffpress5_cfg_setup Config Object Initialization function.
void diffpress5_cfg_setup(diffpress5_cfg_t *cfg)
Diff Press 5 configuration object setup function.
Diff Press 5 Click configuration object.
Definition diffpress5.h:162
- diffpress5_init Initialization function.
err_t diffpress5_init(diffpress5_t *ctx, diffpress5_cfg_t *cfg)
Diff Press 5 initialization function.
Diff Press 5 Click context object.
Definition diffpress5.h:146
- diffpress5_default_cfg Click Default Configuration function.
- diffpress5_calib_offset This function calibrates the zero current offset value.
err_t diffpress5_calib_offset(diffpress5_t *ctx)
Diff Press 5 calib offset function.
- diffpress5_read_vout_avg This function reads a desired number of sensor voltage output samples and averages it.
err_t diffpress5_read_vout_avg(diffpress5_t *ctx, uint16_t num_conv, float *vout_avg)
Diff Press 5 read vout avg function.
- diffpress5_read_pressure This function reads the differential pressure measurement.
err_t diffpress5_read_pressure(diffpress5_t *ctx, uint16_t *pressure)
Diff Press 5 read pressure function.
Application Init
Initializes the logger and the Diff Press 5 Click driver. The application then performs zero-pressure offset calibration to ensure accurate pressure measurements. During the calibration, it is crucial to avoid applying pressure to the sensor.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, " Calibrating zero pressure offset in 5 seconds...\r\n" );
log_printf( &logger, " Make sure no pressure is applied to the sensor during the calibration process.\r\n" );
for ( uint8_t cnt = 5; cnt > 0; cnt-- )
{
log_printf( &logger, " %u\r\n", ( uint16_t ) cnt );
Delay_ms ( 1000 );
}
{
log_error( &logger, " Calibrate offset." );
for ( ; ; );
}
log_printf( &logger, " Offset calibration DONE.\r\n\n" );
log_info( &logger, " Application Task " );
}
@ DIFFPRESS5_ERROR
Definition diffpress5.h:184
#define DIFFPRESS5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition diffpress5.h:122
void application_init(void)
Definition main.c:38
#define MIKROBUS_POSITION_DIFFPRESS5
Definition main.c:32
Application Task
Continuously reads the differential pressure from the sensor and logs the values in Pascals (Pa).
{
uint16_t pressure = 0;
{
log_printf( &logger, " Pressure : %u Pa\r\n\n", pressure );
}
}
@ DIFFPRESS5_OK
Definition diffpress5.h:183
void application_task(void)
Definition main.c:83
Note
The measurable pressure range of the sensor is 0 to 10000 Pa.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.